package com.oak.gateway8888;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * com.oak.gateway8888 -> GateWayConfig
 *
 * @Author: guoxy
 * @Description:
 * @Date: 2022/7/3
 */
@Configuration
public class GateWayConfig {

    /**
     * 代码形式配置路由规则（推荐yml配置方式）
     * 代理百度地址
     * 配置规则：https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#gateway-request-predicates-factories
     *
     * @param builder
     * @return
     */
    @Bean
    public RouteLocator cu(RouteLocatorBuilder builder){
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("patch_route_baidu",r->r.path("/baidu").uri("https://note.youdao.com/")).build();
        return routes.build();
    }
}